<div class="popup-mask hidden"></div>
<div class="bottom-popup__mask hidden"></div>
<div class="bottom-popup comment-bottom-popup hidden">
    <div class="bottom-popup__header">
        <h6 class="bottom-popup__header-title">发表回复</h6>
    </div>
    <form action="" class="ajax-form" id="add-msg-form" method="post">
        <div class="hidden" id="msg-input-list"></div>
        <div class="bottom-popup__content">
            <textarea name="content" id="reply-content" rows="10" placeholder="请输入你的回复"></textarea>
        </div>
        <div class="bottom-popup__footer">
            <a class="text-light-black close-bottom-popup" href="javascript:;">取消</a>
            <button type="submit" class="text-blue reply-content">发布</button>
        </div>
    </form>
</div>


<script src="__PUBLIC__/static/mobile/dist/js/app-8141f6f0f5.js"></script>
<script>
    $(function () {
        // var message_id = 0;
        var jsonMsgData;
        var msgUrl;
        let bp = new BottomPopup('.bottom-popup');
        $('body').on('click', '.add-reply', function () {
            var title = $(this).text();
            jsonMsgData = $(this).data('json');
            let str = '';
            if(jsonMsgData){
                for(var i in jsonMsgData){
                    str += '<input type="hidden" name="'+i+'" value="'+jsonMsgData[i]+'">';
                }
            }
            $('#msg-input-list').html(str);
            // jsonMsgData = JSON.parse(jsonMsgData);
            msgUrl = $(this).data('url');
            $('#add-msg-form').attr('action', msgUrl);
            $('.bottom-popup__header-title').text(title);
            bp.show();
            // message_id = $(this).data('id');
            // console.log(message_id)
        });
        // 回复的id
        var reply_id =0;
        $('body').on('click', '.delete-reply', function () {
            reply_id = $(this).data('id');
            $.msgBox({
                title: "提示",
                content:'确定删除该回复？',
                buttons: [
                    {
                        value: '确定'
                    },
                    {
                        value: '取消'
                    }
                ],
                success: function (v) {
                    if(v === '确定'){
                        $.ajax({
                            type: "POST",
                            url: "{:U('/home/Message/deleteMsg')}",
                            data: {id:reply_id},
                            dataType: 'json',
                            success: function(msg){
                                if (msg.status == 1){
                                    if (msg.url){
                                        window.location = msg.url
                                    } else {
                                        window.location.reload();
                                    }
                                } else {
                                    $.msgBox({
                                        title: "提示",
                                        content:msg.info,
                                        afterClose: function () {
                                            if (msg.url){
                                                window.location = msg.url
                                            }
                                        }
                                    });
                                }
                                console.log(msg);
                            }
                        });
                    }
                }
            });
        });
    })
</script>

<block name="script"></block>